/**
 * Created by Administrator on 2017/3/13.
 */
$(function(){
    var local=JSON.parse(sessionStorage.getItem('location'));
    $.get(salerDetail,{jishi_id:getQueryString('id'),lat:local.latitude,lng:local.longitude},function(data) {
        if (data) {
            //加载购物车数据
            updateCart();
            var res = JSON.parse(data);
            console.log(res);
            $('.personnel_up>img').attr('src', res.avatar);
            $('.personnel_name>b').html(res.nickname);
            $('.name_dingdan>b').html(res.scoreC);
            var htmlxing='';
            var len=(Math.round(res.scoreS/res.scoreC||0)<1)?5:Math.round(res.scoreS/res.scoreC||0);
            for(var i=0;i<len;i++){
                    htmlxing+='<i style="color: #ff5c67" class="iconal-xing"></i>';
            }
            $('.personnel_pingjia>span:last-child').html(htmlxing);//总评价 星
            $('.personnel_name>span:nth-child(2)').html(res.sex);
            var juli = '';
            var kefuMQ=res.kefu;
            if (Number(res.distance) > 2000) {
                juli = (Number(res.distance) / 1000).toFixed(2) + '公里';
            } else {
                juli = res.distance + '米';
            }
            $('.personnel_address>span').html(juli);
            $('.personnel>a>div').html('<p>工作经验:  <span>' + res.content + '</span></p>');//<p>门店地址:  <span>' + data.store.address + '</span></p>
            var html = '';
            for (var i = 0; i < res.goods.length; i++) {
                var deliverytype=res.goods[i].deliverytype=='1'?'上门':'到店';
                html+='<div class="lists_data"><div class="data_img"><img onclick="gotoDetail(this)" data-option='+res.goods[i].hasoption+' data-id='+res.goods[i].id+' src='+res.goods[i].gimg+' alt=""/></div>'
                +'<div><div class="data_title"><b>'+res.goods[i].gname+'</b></div>'
                +'<div class="data_price">￥<b>'+res.goods[i].oprice+'</b><s>￥'+res.goods[i].mprice+'</s>'
                +'<i class="iconal-yuebiao" onclick="yuebiaoClick(this,event)" data-id='+res.goods[i].id+' data-type='+res.goods[i].deliverytype+' data-params='+JSON.stringify(res.goods[i].params)+'></i>'
                +'</div><div class="data_time"><ul><li class="data-type"><span>'+deliverytype+'</span></li><li style="width: 5em"><i class="iconal-zuyue"></i><span>'+res.goods[i].endtime+'</span>分钟</li>'
                +'<li><i class="iconal-qunzuduoren"></i><span>'+res.goods[i].salenum+'人做过</span></li></ul></div></div></div>'
            }
            $('.lists').html(html);
            if(Number(kefuMQ)>0) {
                //美洽客服(按钮)
                $('#MQkefu').attr('href','https://static.meiqia.com/dist/standalone.html?eid='+kefuMQ);
            }else{
                $('#MQkefu').css('display','none');
            }
        } else {
            location.href = personnelUrl;
        }
    })
});

$('.personnel>a.weui-cell').click(function(){
    var span=$('.personnel>a.weui-cell>span');
    if(span.hasClass('iconal-xiangxiajiantou')){
        span.removeClass('iconal-xiangxiajiantou').addClass('iconal-xiangshangjiantou');
        $('.personnel>a.weui-cell').css('height','inherit')
    }else{
        span.removeClass('iconal-xiangshangjiantou').addClass('iconal-xiangxiajiantou');
        $('.personnel>a.weui-cell').css('height','30px')
    }
});


//跳转到详情页
$('.data_img').on('click',function(e){
    var id=11;
    location.href="index_detail.html?id="+id;
});









